package com.pkt.item.service;

import com.item.piketao.dao.SpecGroup;
import com.item.piketao.dao.SpecParam;
import com.pkt.item.mapper.SpecGroupMapper;
import com.pkt.item.mapper.SpecParamMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author: xinglongge
 * @Date: 2020/3/4 15 38
 * @Description:
 */
@Service
public class SpecificationService {

    private final SpecGroupMapper specGroupMapper;

    private final SpecParamMapper specParamMapper;

    @Autowired
    public SpecificationService(SpecGroupMapper specGroupMapper, SpecParamMapper specParamMapper) {
        this.specGroupMapper = specGroupMapper;
        this.specParamMapper = specParamMapper;
    }

    public List<SpecGroup> queryGroupsByCid(Long cid) {
        SpecGroup record = new SpecGroup();
        record.setCid(cid);
        return specGroupMapper.select(record);
    }

    /**
     * 查询规格参数
     * @param gid
     * @return
     */
    public List<SpecParam> queryParams(Long gid,Long cid,Boolean generic,Boolean search) {
        SpecParam record = new SpecParam();
        record.setGroupId(gid);
        record.setCid(cid);
        record.setGeneric(generic);
        record.setSearching(search);
        return  specParamMapper.select(record);


    }
}
